from aiogram_dialog import DialogManager
from sqlalchemy.ext.asyncio import AsyncSession

from app.bot.services.locale import Locale
from app.database.services.payments import get_payment


async def payment_getter(
    db_session: AsyncSession, dialog_manager: DialogManager, **kwargs
):

    payment_id: int = dialog_manager.dialog_data.get("payment_id")
    payment = await get_payment(db_session, payment_id)

    locale: Locale = dialog_manager.middleware_data.get("locale")
    status = locale.get(payment.status)

    return {
        "payment_id": payment.id,
        "payment_summ": payment.summ,
        "status": status,
        "created_at": payment.created_at,
    }
